<!DOCTYPE html>
<html dir="ltr">

<head>
  <meta charset="UTF-8">
  <title>Nav Push</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  <link href="../../../../../css/ionic.bundle.css" rel="stylesheet">
  <link href="../../../../../scripts/testing/styles.css" rel="stylesheet">
  <script src="../../../../../scripts/testing/scripts.js"></script>
  <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
  <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script></head>

<body onload="loadFirstPage()">
  <ion-app>
    <ion-nav></ion-nav>
  </ion-app>
  <style>
    f {
      display: block;
      margin: 15px auto;
      max-width: 150px;
      height: 150px;
      background: blue;
    }

    f:last-of-type {
      background: yellow;
    }

  </style>
</body>

<script>

  class FirstPage extends HTMLElement {
    async connectedCallback() {
      this.innerHTML = `

        <ion-header>
          <ion-toolbar>
            <ion-title>Page One</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content class="ion-padding">
          <h1>Page One</h1>
          <ion-nav-link router-direction="forward" component="page-two">
            <ion-button class="next">Go to Page Two</ion-button>
          </ion-nav-link>
        </ion-content>
      `;
    }
  }

  class SecondPage extends HTMLElement {
    async connectedCallback() {
      this.innerHTML = `

        <ion-header>
          <ion-toolbar>
            <ion-title>Page Two</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content class="ion-padding">
          <h1>Page Two</h1>
          <ion-nav-link router-direction="forward" component="page-three">
            <ion-button class="next">Go to Page Three</ion-button>
          </ion-nav-link>
          <ion-nav-link router-direction="back">
            <ion-button class="back">Go Back</ion-button>
          </ion-nav-link>
        </ion-content>
      `;
    }
  }

  class ThirdPage extends HTMLElement {
    async connectedCallback() {
      this.innerHTML = `

        <ion-header>
          <ion-toolbar>
            <ion-title>Page Three</ion-title>
          </ion-toolbar>
        </ion-header>
        <ion-content class="ion-padding">
          <h1>Page Three</h1>
          <ion-nav-link router-direction="back">
            <ion-button class="back">Go Back</ion-button>
          </ion-nav-link>
        </ion-content>
      `;
    }
  }

  customElements.define('page-one', FirstPage);
  customElements.define('page-two', SecondPage);
  customElements.define('page-three', ThirdPage);

  async function loadFirstPage() {
    const nav = document.querySelector('ion-nav');
    await nav.setRoot('page-one');
  }
</script>

</html>
